//
//  RootNavigationViewController.m
//  iPlan
//
//  Created by 侯伟 on 2021/10/11.
//

#import "RootNavigationViewController.h"
#import "QXAdvertManager.h"

@interface RootNavigationViewController ()<QXAdvertDelegate,UINavigationControllerDelegate>

@end

@implementation RootNavigationViewController

- (void)loadView{
    [super loadView];
    [self loadAd];
}

- (void)viewDidLoad{
    [super viewDidLoad];
}

#pragma mark -- loadAd

//ad
- (void)loadAd{
    [QXAdvertManager manager].delegate = self;
    [[QXAdvertManager manager] loadSplashAdWithRootViewController:self];
}


#pragma mark -- <QXadverSDKDelegate>
//获取广告类型
- (void)QXAdTypeDidLoaded:(ADType)adType success:(BOOL)success{
    if(!success && adType == ADType_Splash){
        [[NSNotificationCenter defaultCenter] postNotificationName:kAdCompleteNotification object:NULL];
    }
}

//加载失败
- (void)QXAdLoadFaild:(ADType)adType adChannel:(ADChannel)adChannel error:(NSError *)error{
    if(adType == ADType_Splash){
        [[NSNotificationCenter defaultCenter] postNotificationName:kAdCompleteNotification object:NULL];
    }
}

//显示出来
- (void)QXAdDidDisplayed:(ADType)adType adChannel:(ADChannel)adChannel ad:(id)ad{
    if(adType == ADType_Splash){
        [[NSNotificationCenter defaultCenter] postNotificationName:kAdCompleteNotification object:NULL];
    }
}

//展示失败
- (void)QXAdDisplayFaild:(ADType)adType adChannel:(ADChannel)adChannel error:(NSError *)error{
    if(adType == ADType_Splash){
        [[NSNotificationCenter defaultCenter] postNotificationName:kAdCompleteNotification object:NULL];
    }
}


#pragma mark -- UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
    [self setNavigationBarHidden:YES animated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

